package com.inspector.app.ui.vo

import android.os.Parcel
import android.os.Parcelable
import com.inspector.app.di.util.UI
import com.inspector.app.util.LogUtil
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize

//https://console-docs.apipost.cn/preview/0d1598f3327886d1/9f4032ed61a7b4b7?target_id=9f8eff43-699d-42ce-986b-852c62bd2711
@Parcelize
data class TaskItem(

    //[系统任务列表参数]
    val id: String? = null,             //[任务id]
    val companyId: String? = null,      //公司id
    val taskTitle: String? = null,      //任务标题(模糊查询)
    val taskAddress: String? = null,    //任务地址
    val lng: Double? = null,    //经度
    val lat: Double? = null,    //纬度
    val lngString: String? = null,
    val latString: String? = null,
    val startTime: String? = null,  //"2024-07-12 00:00:00", //发布-开始时间
    val endTime: String? = null,    //"2024-07-19 00:00:00", //发布-结束时间
    val des: String? = null,        //描述
    val status: Int? = null,     //状态，0下发，1不下发，2共享，3不共享
    val createTime: String? = null, //"2024-07-04 15:45:47", //创建时间
    val createUserName: String? = null, //发起人
    val hasAuth: Boolean? = null, //是否有权限

    //[我的任务列表参数]
//    val status: Int? = null, //任务状态：'1未开始 2进行中 3已完成 4手动终止'
    val attachment: String? = null, //附件guid
    val flyPlanId: String? = null, //飞行计划id
    val autoStart: Int? = null, //'自动开始 1是 2否',
    val autoEnd: Int? = null,   //'自动结束 1是 2否',
    val allowIn: Int? = null,   //'允许加入 1是 2否'
    val autoAnalyse: Int? = null,   //???
    val isDelete: Int? = null,   //???
    val deleteTime: String? = null,   //???
    val modifyTime: String? = null,   //??? //修改时间'收到地图消息是否自动解析绘制 1是 2否',
//    val createTime: String? = null,
    val createUserId: String? = null,
    val modifyUserId: String? = null,
    val deleteUserId: String? = null,
    val remark: String? = null,      //备注
    val pass: String? = null,   //查看密码
    val teamsNum: Int? = null,  //小组数量
    val zhNum: Int? = null,    //指挥员数量
    val waitCheckNum: Int? = null,    //
    val authen: Int? = null,   //权限 1：执行 2：查看
    val describe: String? = null,   //权限 1：执行 2：查看
//    val attachmentList: MutableList<String>? = null,   //附件列表
    val flyPlanName: String? = null,
//    val createUserName: String? = null,

): Parcelable {

    fun getSystemTaskStatus(): String = try {
        //状态，0下发，1不下发，2共享，3不共享
        val systemStatus = arrayOf("下发", "不下发", "共享", "不共享")
        if (status == null) "--" else systemStatus[status]
    } catch (e: Exception) {
        "--"
    }

    fun getMyTaskStatus(): String = try {
        //1未开始 2进行中 3已完成 4手动终止
        val myStatus = arrayOf("--", "未开始", "进行中", "已完成", "已终止")
        if (status == null) "--" else myStatus[status]
    } catch (e: Exception) {
        "--"
    }

    fun getStartAndEndTime(): String = try {
        //"2024-07-12 00:00:00", //发布-开始时间
        val formatStartDate =
            UI.formatStringDate(startTime, "yyyy-MM-dd HH:mm:ss", "yyyy年MM月dd日 HH:mm")
        val formatEndDate =
            UI.formatStringDate(startTime, "yyyy-MM-dd HH:mm:ss", "yyyy年MM月dd日 HH:mm")
        "$formatStartDate ~ $formatEndDate"
    } catch (e: Exception) {
        "--"
    }

    fun getFormatLngLatitude(): String {
        if (latString.isNullOrEmpty() && lngString.isNullOrEmpty()) {
            return "--"
        }
        val formatLngString = if (lngString.isNullOrEmpty()) "--" else lngString
        val formatLatString = if (latString.isNullOrEmpty()) "--" else latString
        return "$formatLngString/$formatLatString"
    }



}


@Parcelize
data class Params(
    var pageNumber: Int = 1,
    var pageSize: Int = 20,
    var taskTitle: String? = "",
    var status: String? = "",
    var startTime: String? = "",
    var endTime: String? = "",
    var systemTaskPos: Boolean = true,
): Parcelable
